package com.hn658.base.message.app.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.hn658.base.message.app.service.IAppInfoManager;
import com.hn658.framework.common.AbstractBusinessObject;
import com.hn658.framework.dataaccess.pagination.GenericPage;
import com.hn658.framework.shared.exception.BusinessException;
import com.hn658.message.config.service.IBaseMessageConfig;
import com.hn658.user.itf.ItfAppInfoService;
import com.hn658.user.itf.vo.AppInfoDTO;
import com.hn658.user.itf.vo.AppInfoResponse;

@Component
public class AppInfoManagerImpl extends AbstractBusinessObject implements
		IAppInfoManager {

	@Autowired
	private ItfAppInfoService itfAppInfoService;

	@Autowired
	private IBaseMessageConfig messageConfig;

	@Override
	public AppInfoDTO findCurrentAppInfo()
			throws BusinessException {
		String appId = messageConfig.getAppId();
		AppInfoResponse response = itfAppInfoService.findAppInfoByAppId(appId);
		return response.getAppInfo();
	}
	
	@Override
	public AppInfoDTO findAppInfoByAppId(String appId)
			throws BusinessException {
		AppInfoResponse response = itfAppInfoService.findAppInfoByAppId(appId);
		return response.getAppInfo();
	}

	@Override
	public GenericPage<AppInfoDTO> findAppInfo(Map<String, Object> queryMap,
			int pageSize, int start) {
		AppInfoResponse response = itfAppInfoService.findAppInfoPageByMap(queryMap, pageSize, start);
		GenericPage<AppInfoDTO> appInfoPage=new GenericPage<AppInfoDTO>();
		appInfoPage.setData(response.getAppInfoList());
		appInfoPage.setTotalCount(response.getTotalCount());
		appInfoPage.setPageSize(pageSize);
		appInfoPage.setStart(start);
		return appInfoPage;
	}

}